﻿namespace HySoft.Cash.Business
{
    using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.DB;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;
    using System.Web.UI;

    public class TdocumentsBN : BaseBusiness
    {
        private TdocumentsDB db;

        public TdocumentsBN(Page page) : base(page)
        {
            this.db = null;
            this.db = new TdocumentsDB(base.curDBOperater);
        }

        public TdocumentsBN(Page page, DBOperate oper) : base(page, oper)
        {
            this.db = null;
            this.db = new TdocumentsDB(base.curDBOperater);
        }

        public bool Add(TdocumentsDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Add(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public bool Delete(int Sid)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Delete(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public void Dispose()
        {
            base.Dispose();
            if (this.db != null)
            {
                this.db = null;
            }
        }

        public bool Edit(TdocumentsDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Edit(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public TdocumentsDT Get(int Sid)
        {
            TdocumentsDT sdt = null;
            try
            {
                try
                {
                    sdt = this.db.Get(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return sdt;
        }

        public DataTable GetList()
        {
            base.DBFieldList = "Sid,Filename,Filepath,Pubdate,Usersid,Note";
            base.DBTable = "tDocuments";
            return base.CommonGetList();
        }

        public void QueryFilename(string Filename)
        {
            if ((Filename != null) && (Filename.Trim() != ""))
            {
                base.Filter = "Filename like '%" + StringUtils.ToSQL(Filename) + "%'";
            }
        }

        public void QueryFilepath(string Filepath)
        {
            if ((Filepath != null) && (Filepath.Trim() != ""))
            {
                base.Filter = "Filepath like '%" + StringUtils.ToSQL(Filepath) + "%'";
            }
        }

        public void QueryNote(string Note)
        {
            if ((Note != null) && (Note.Trim() != ""))
            {
                base.Filter = "Note like '%" + StringUtils.ToSQL(Note) + "%'";
            }
        }

        public void QueryPubdate(string Pubdate)
        {
            if ((Pubdate != null) && (Pubdate.Trim() != ""))
            {
                base.Filter = "Pubdate like '%" + StringUtils.ToSQL(Pubdate) + "%'";
            }
        }

        public void QuerySid(int Sid)
        {
            base.Filter = "Sid= " + Sid;
        }

        public void QueryUsersid(int Usersid)
        {
            base.Filter = "Usersid= " + Usersid;
        }
    }
}

